﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlDataReader reader = null;
            string Name = null;
            string pwd = null;
            try
            {
                if (textBox2.Text == "" || textBox1.Text == "")
                {
                    MessageBox.Show("账号或密码不能为空");
                }
                else { 
                string sql = string.Format("select *from Order1 where Id='"+textBox1.Text+"' and Pwd='"+textBox2.Text+"'");
                reader = sqlCommom.Select(sql);
                while (reader.Read())
                {
                    Name = reader["Id"].ToString();
                    pwd = reader["pwd"].ToString();
                }
                reader.Close();
                if (Name == textBox1.Text && pwd == textBox2.Text)
                {
                    MessageBox.Show("登录成功");
                }
                else 
                {
                    MessageBox.Show("账号或密码错误，请重新输入");
                }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("不明错误：" + ex.Message);
            }
        }
    }
}
